/**
 * // ============================================================================
 * //
 * // Copyright (C) 2006-2007 Dengues
 * //
 * // Google Group: http://groups.google.com/group/dengues
 * // QQ Group: 24885404
 * //
 * // This library is free software; you can redistribute it and/or
 * // modify it under the terms of the GNU Lesser General Public
 * // License as published by the Free Software Foundation; either
 * // version 2.1 of the License.
 * //
 * // This library is distributed in the hope that it will be useful,
 * // but WITHOUT ANY WARRANTY; without even the implied warranty of
 * // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * // Lesser General Public License for more details.
 * //
 * // You should have received a copy of the GNU General Public License
 * // along with this program; if not, write to the Free Software
 * // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 * //
 * // ============================================================================
 * 
 *
 * $Id$
 */
package org.dengues.model.database.impl;

import org.dengues.model.database.DatabasePackage;
import org.dengues.model.database.FKBendpoint;
import org.dengues.model.database.ForeignKey;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EcoreUtil;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>FK Bendpoint</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getWeight <em>Weight</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getFirstW <em>First W</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getFirstH <em>First H</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getSecondW <em>Second W</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getSecondH <em>Second H</em>}</li>
 *   <li>{@link org.dengues.model.database.impl.FKBendpointImpl#getForeignKey <em>Foreign Key</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class FKBendpointImpl extends EObjectImpl implements FKBendpoint {
    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public static final String copyright = "// ============================================================================\r\n//\r\n// Copyright (C) 2006-2007 Dengues\r\n//\r\n// Google Group: http://groups.google.com/group/dengues\r\n// QQ Group: 24885404\r\n//\r\n// This library is free software; you can redistribute it and/or\r\n// modify it under the terms of the GNU Lesser General Public\r\n// License as published by the Free Software Foundation; either\r\n// version 2.1 of the License.\r\n//\r\n// This library is distributed in the hope that it will be useful,\r\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\r\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\r\n// Lesser General Public License for more details.\r\n//\r\n// You should have received a copy of the GNU General Public License\r\n// along with this program; if not, write to the Free Software\r\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r\n//\r\n// ============================================================================\r\n";

    /**
     * The default value of the '{@link #getWeight() <em>Weight</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getWeight()
     * @generated
     * @ordered
     */
    protected static final float WEIGHT_EDEFAULT = 0.0F;

    /**
     * The cached value of the '{@link #getWeight() <em>Weight</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getWeight()
     * @generated
     * @ordered
     */
    protected float weight = WEIGHT_EDEFAULT;

    /**
     * The default value of the '{@link #getFirstW() <em>First W</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getFirstW()
     * @generated
     * @ordered
     */
    protected static final int FIRST_W_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getFirstW() <em>First W</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getFirstW()
     * @generated
     * @ordered
     */
    protected int firstW = FIRST_W_EDEFAULT;

    /**
     * The default value of the '{@link #getFirstH() <em>First H</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getFirstH()
     * @generated
     * @ordered
     */
    protected static final int FIRST_H_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getFirstH() <em>First H</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getFirstH()
     * @generated
     * @ordered
     */
    protected int firstH = FIRST_H_EDEFAULT;

    /**
     * The default value of the '{@link #getSecondW() <em>Second W</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getSecondW()
     * @generated
     * @ordered
     */
    protected static final int SECOND_W_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getSecondW() <em>Second W</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getSecondW()
     * @generated
     * @ordered
     */
    protected int secondW = SECOND_W_EDEFAULT;

    /**
     * The default value of the '{@link #getSecondH() <em>Second H</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getSecondH()
     * @generated
     * @ordered
     */
    protected static final int SECOND_H_EDEFAULT = 0;

    /**
     * The cached value of the '{@link #getSecondH() <em>Second H</em>}' attribute.
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @see #getSecondH()
     * @generated
     * @ordered
     */
    protected int secondH = SECOND_H_EDEFAULT;

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    protected FKBendpointImpl() {
        super();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    protected EClass eStaticClass() {
        return DatabasePackage.Literals.FK_BENDPOINT;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public float getWeight() {
        return weight;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setWeight(float newWeight) {
        float oldWeight = weight;
        weight = newWeight;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__WEIGHT, oldWeight, weight));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getFirstW() {
        return firstW;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setFirstW(int newFirstW) {
        int oldFirstW = firstW;
        firstW = newFirstW;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__FIRST_W, oldFirstW, firstW));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getFirstH() {
        return firstH;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setFirstH(int newFirstH) {
        int oldFirstH = firstH;
        firstH = newFirstH;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__FIRST_H, oldFirstH, firstH));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getSecondW() {
        return secondW;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setSecondW(int newSecondW) {
        int oldSecondW = secondW;
        secondW = newSecondW;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__SECOND_W, oldSecondW, secondW));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public int getSecondH() {
        return secondH;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setSecondH(int newSecondH) {
        int oldSecondH = secondH;
        secondH = newSecondH;
        if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__SECOND_H, oldSecondH, secondH));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public ForeignKey getForeignKey() {
        if (eContainerFeatureID != DatabasePackage.FK_BENDPOINT__FOREIGN_KEY) return null;
        return (ForeignKey)eContainer();
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public NotificationChain basicSetForeignKey(ForeignKey newForeignKey, NotificationChain msgs) {
        msgs = eBasicSetContainer((InternalEObject)newForeignKey, DatabasePackage.FK_BENDPOINT__FOREIGN_KEY, msgs);
        return msgs;
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    public void setForeignKey(ForeignKey newForeignKey) {
        if (newForeignKey != eInternalContainer() || (eContainerFeatureID != DatabasePackage.FK_BENDPOINT__FOREIGN_KEY && newForeignKey != null)) {
            if (EcoreUtil.isAncestor(this, newForeignKey))
                throw new IllegalArgumentException("Recursive containment not allowed for " + toString());
            NotificationChain msgs = null;
            if (eInternalContainer() != null)
                msgs = eBasicRemoveFromContainer(msgs);
            if (newForeignKey != null)
                msgs = ((InternalEObject)newForeignKey).eInverseAdd(this, DatabasePackage.FOREIGN_KEY__FK_BENDPOINTS, ForeignKey.class, msgs);
            msgs = basicSetForeignKey(newForeignKey, msgs);
            if (msgs != null) msgs.dispatch();
        }
        else if (eNotificationRequired())
            eNotify(new ENotificationImpl(this, Notification.SET, DatabasePackage.FK_BENDPOINT__FOREIGN_KEY, newForeignKey, newForeignKey));
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                if (eInternalContainer() != null)
                    msgs = eBasicRemoveFromContainer(msgs);
                return basicSetForeignKey((ForeignKey)otherEnd, msgs);
        }
        return super.eInverseAdd(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                return basicSetForeignKey(null, msgs);
        }
        return super.eInverseRemove(otherEnd, featureID, msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) {
        switch (eContainerFeatureID) {
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                return eInternalContainer().eInverseRemove(this, DatabasePackage.FOREIGN_KEY__FK_BENDPOINTS, ForeignKey.class, msgs);
        }
        return super.eBasicRemoveFromContainerFeature(msgs);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public Object eGet(int featureID, boolean resolve, boolean coreType) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__WEIGHT:
                return new Float(getWeight());
            case DatabasePackage.FK_BENDPOINT__FIRST_W:
                return new Integer(getFirstW());
            case DatabasePackage.FK_BENDPOINT__FIRST_H:
                return new Integer(getFirstH());
            case DatabasePackage.FK_BENDPOINT__SECOND_W:
                return new Integer(getSecondW());
            case DatabasePackage.FK_BENDPOINT__SECOND_H:
                return new Integer(getSecondH());
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                return getForeignKey();
        }
        return super.eGet(featureID, resolve, coreType);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eSet(int featureID, Object newValue) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__WEIGHT:
                setWeight(((Float)newValue).floatValue());
                return;
            case DatabasePackage.FK_BENDPOINT__FIRST_W:
                setFirstW(((Integer)newValue).intValue());
                return;
            case DatabasePackage.FK_BENDPOINT__FIRST_H:
                setFirstH(((Integer)newValue).intValue());
                return;
            case DatabasePackage.FK_BENDPOINT__SECOND_W:
                setSecondW(((Integer)newValue).intValue());
                return;
            case DatabasePackage.FK_BENDPOINT__SECOND_H:
                setSecondH(((Integer)newValue).intValue());
                return;
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                setForeignKey((ForeignKey)newValue);
                return;
        }
        super.eSet(featureID, newValue);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public void eUnset(int featureID) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__WEIGHT:
                setWeight(WEIGHT_EDEFAULT);
                return;
            case DatabasePackage.FK_BENDPOINT__FIRST_W:
                setFirstW(FIRST_W_EDEFAULT);
                return;
            case DatabasePackage.FK_BENDPOINT__FIRST_H:
                setFirstH(FIRST_H_EDEFAULT);
                return;
            case DatabasePackage.FK_BENDPOINT__SECOND_W:
                setSecondW(SECOND_W_EDEFAULT);
                return;
            case DatabasePackage.FK_BENDPOINT__SECOND_H:
                setSecondH(SECOND_H_EDEFAULT);
                return;
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                setForeignKey((ForeignKey)null);
                return;
        }
        super.eUnset(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public boolean eIsSet(int featureID) {
        switch (featureID) {
            case DatabasePackage.FK_BENDPOINT__WEIGHT:
                return weight != WEIGHT_EDEFAULT;
            case DatabasePackage.FK_BENDPOINT__FIRST_W:
                return firstW != FIRST_W_EDEFAULT;
            case DatabasePackage.FK_BENDPOINT__FIRST_H:
                return firstH != FIRST_H_EDEFAULT;
            case DatabasePackage.FK_BENDPOINT__SECOND_W:
                return secondW != SECOND_W_EDEFAULT;
            case DatabasePackage.FK_BENDPOINT__SECOND_H:
                return secondH != SECOND_H_EDEFAULT;
            case DatabasePackage.FK_BENDPOINT__FOREIGN_KEY:
                return getForeignKey() != null;
        }
        return super.eIsSet(featureID);
    }

    /**
     * <!-- begin-user-doc -->
     * <!-- end-user-doc -->
     * @generated
     */
    @Override
    public String toString() {
        if (eIsProxy()) return super.toString();

        StringBuffer result = new StringBuffer(super.toString());
        result.append(" (weight: ");
        result.append(weight);
        result.append(", firstW: ");
        result.append(firstW);
        result.append(", firstH: ");
        result.append(firstH);
        result.append(", secondW: ");
        result.append(secondW);
        result.append(", secondH: ");
        result.append(secondH);
        result.append(')');
        return result.toString();
    }

} //FKBendpointImpl
